package com.huawei.gamebox.plugin.gameservice.action;

import android.app.Activity;
import android.content.DialogInterface;
import android.content.DialogInterface.OnDismissListener;
import com.huawei.appgallery.assistantdock.base.externalaction.openviewaction.IOpenViewAction;
import com.huawei.appgallery.assistantdock.base.externalaction.openviewaction.RemoteBuoyAction;
import com.huawei.gamebox.service.welfare.gift.bean.GiftCardBean;
import com.huawei.secure.android.common.intent.SafeIntent;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import o.Logger;
import o.dys.a;
import o.fcb;

public class OpenRoleSelectDialogAction extends IOpenViewAction {
    private static final String TAG = "OpenRoleSelectDialogAction";

    static class RoleSelectDialogDismissListener implements OnDismissListener {
        private WeakReference<Activity> activity;

        RoleSelectDialogDismissListener(Activity activity) {
            this.activity = new WeakReference(activity);
        }

        public void onDismiss(DialogInterface dialogInterface) {
            if (this.activity != null) {
                Activity activity = (Activity) this.activity.get();
                if (activity != null) {
                    try {
                        if (!activity.isFinishing()) {
                            activity.finish();
                        }
                    } catch (Exception e) {
                        Logger.e(OpenRoleSelectDialogAction.TAG, "finish TransferActivity exception");
                    }
                }
            }
        }
    }

    public OpenRoleSelectDialogAction(a aVar, SafeIntent safeIntent) {
        super(aVar, safeIntent);
    }

    public void onAction() {
        dispatchOpenGiftSelectDialog();
    }

    private void dispatchOpenGiftSelectDialog() {
        if (this.callback instanceof Activity) {
            Activity activity = (Activity) this.callback;
            fcb.ˏ(activity, (ArrayList) this.intent.getSerializableExtra(RemoteBuoyAction.REMOTE_BUOY_PARAM), (GiftCardBean) this.intent.getSerializableExtra("cardbean"), this.intent.getIntExtra("service_type", 5), new RoleSelectDialogDismissListener(activity));
            return;
        }
        Logger.ˎ(TAG, "callback is not activity, finish");
        this.callback.finish();
    }
}
